package justdoit.view.model;

import java.io.File;
import java.io.IOException;

import javax.swing.JFileChooser;
import javax.swing.JPanel;


public class ExcelFileChooserView extends JPanel{

	JFileChooser fc;
	File file;
	
	public File getFile() {
		return file;
	}
	public void setFile(File file) {
		this.file = file;
	}
	public ExcelFileChooserView()
	{
		fc = new JFileChooser();
		int returnVal = fc.showSaveDialog(this);
//		int returnVal = fc.showOpenDialog(ExcelFileChooserView.this);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            file = fc.getSelectedFile();
            if(!file.exists())
            {
				try {
					file.createNewFile();
				} catch (IOException e) {
					e.printStackTrace();
				}
				
            }
        }
        else {
        		System.out.println("File open Cancelled By the User");
        }
	 
	}
}
